<template>
    <div>
    <h2>人员信息</h2>
    <div class="buttoncon">
    <Button type="primary"  @click="go">返回上一页</Button>
    <div class="sharch">
       <div  class="name">
         <Input v-model.trim="Names" placeholder="姓名"  style="width: 200px" />
          <Button type="primary" @click="shearNames">搜索</Button>
        </div>
          <div class="phones">
          <Input v-model.trim="Phones" placeholder="手机号"  style="width: 200px" />
          <Button type="primary" @click="shearPhones">搜索</Button>
       </div>
        </div>
    </div>
        <Table border :loading="loading" :columns="columns1"  :data="data1">
        </Table>
        <br>
    </div>
</template>
<script type="text/javascript">
    export default{
        data(){
            return{

                    Names: '',
                    Phones:'',
                    Sku:'',
                     Sku_z:'',
                     Date_z:'',
                     datalisting:'',
                    loading: true,
                columns1: [
                    {
                        title: '姓名',
                        key: 'name',
                        align: 'center',
           
                    },
                    {
                        title: '手机',
                        key: 'phone',
                        align: 'center',
                
                    },
                      {
                        // 过期时间  studyDueTime 研习社  mbaDueTime 商学院   创新院 innovateDueTime
                        // 购买时间  studyDueTime 研习社  mbaDueTime 商学院   创新院 innovateDueTime
                        title: '注册时间',
                        key: 'registerTime',
                        align: 'center'          
                    },
                   {
                        title: '研习社过期时间',
                        key: 'studyDueTime',
                        align: 'center'
                    },
                     {
                        title: '研习社购买时间',
                        key: 'studyBuyTime',
                        // slot: 'action',
                        align: 'center',
                           render: (h, params) => {
                            if ( this.datalisting[params.index].user.studyBuyTime!="") {
                           return  h('ul', this.datalisting[params.index].user.studyBuyTime.map(item => {
                                        return h('li', {
                                            style: {
                                                textAlign: 'center',
                                                padding: '4px'
                                            }
                                        },this.Util.datatime(Number(item)))
                                    }))           
                             
                           }
                      }
                 
                    },
                     {
                        title: '商19购买时间',
                        key: 'mba19BuyTime',
                        align: 'center',
                              render: (h, params) => {
                                if ( this.datalisting[params.index].user.mba19BuyTime!="") 
                                  {
                                     return  h('ul', this.datalisting[params.index].user.mba19BuyTime.map(item => {
                                        return h('li', {
                                            style: {
                                                textAlign: 'center',
                                                padding: '4px'
                                            }
                                        },this.Util.datatime(Number(item)))
                                    }))  
                                  }
                                  
                                   
                             
                           }
                    },
                     {
                        title: '推荐人数',
                        key: 'recommendCount',
                        align: 'center'
                    },
                   {
                        title: '商学院2019学习时长',
                        key: 'mba19LearnDuration',
                        align: 'center'
                    },
                   {
                        title: '研习社学习时长',
                        key: 'studyLearnDuration',
                        align: 'center'
                    },
                    {
                        title: '创新院学习时长',
                        key: 'innovateLearnDuration',
                        align: 'center'
                    }


                ],
                data1: [],
                datacxy:{
                  sxy19Zyxscount:0,
               sxy18Zyxscount:0,
               cxyZyxscount:0,
              sxy18Andsxy19Zyxscount:0,
                sxy18AndcxyZyxscount:0,
               sxy19AndcxyZyxscount:0,
                sxy18Andsxy19AndcxyZyxscount:0
                }
            }
        },

created(){
              var hours =this.Util.datahours(10000)
                  // console.log(hours)
          var that =this;
               console.log(this.$route.query.sku)
               console.log(this.$route.query.sku_z)
               console.log(this.$route.query.date_z)

             this.Sku =this.$route.query.sku
             this.Sku_z =this.$route.query.sku_z
            this.Date_z =this.$route.query.date_z
      // return false
  if (typeof   this.Date_z=="undefined"|| this.Date_z=="%E5%90%88%E8%AE%A1") 
    {
       this.Date_z=" "
    } 
    
  var URL=this.Util.URL()+'/v1/buy-stat/user-list?sku='+this.Sku+'&sku_z='+this.Sku_z+'&date_z='+this.Date_z
this.datalist(URL)

    },
 methods: {
    shearNames(){
  // 姓名搜索---------------------------------------
       var URL=this.Util.URL()+'/v1/buy-stat/user-list?sku='+this.Sku+'&sku_z='+this.Sku_z+'&date_z='+this.Date_z+'&name='+this.Names
this.datalist(URL)
    },
shearPhones(){
  // 手机号搜索---------------------------------------
     var URL=this.Util.URL()+'/v1/buy-stat/user-list?sku='+this.Sku+'&sku_z='+this.Sku_z+'&date_z='+this.Date_z+'&phone='+this.Phones
this.datalist(URL)
    },
      go() {
             this.$router.back(-1)
               // console.log(3333) 
            },
   imgWD(o){
        for (var i = 0; i < o.length; i++) {
            var timew=o[i]
        }
       return  this.Util.datatime(timew)
    },
  datalist(URL){
    var that =this;
     this.axios({
                method: 'get',
                url: URL
              }).then(function (res) { 
                      console.log(res)
                      console.log(res.data.data)
                      var Datas =res.data.data
                      that.datalisting =res.data.data;
                      that.data1.splice(0);
                        for (var i = 0; i < Datas.length; i++) {
                        // var arr = Datas[i].user.studyBuyTime.join(",");
                         that.data1.push({
                          phone:Datas[i].user.phone,
                          name:Datas[i].user.name,
                          registerTime:that.Util.datatime(Number(Datas[i].user.registerTime)),
                          studyDueTime:that.Util.datatime(Number(Datas[i].user.studyDueTime)),
                          // studyBuyTime: arr ,
                          recommendCount:Datas[i].user.recommendCount,
                          mba19LearnDuration:that.Util.datahours(Number(Datas[i].user.mba19LearnDuration)),
                          studyLearnDuration:that.Util.datahours(Number(Datas[i].user.studyLearnDuration)),
                          innovateLearnDuration:that.Util.datahours(Number(Datas[i].user.innovateLearnDuration))
                         })
                      }

                         // }
                         
                    



              }).catch(function (error) {
                console.log(error)
              }).finally(() => this.loading = false)
    }
        
 }
    }
</script>
<style scoped>
    h2{
        text-align: center;
        margin-bottom: 10px;
     }
 .buttoncon{
      margin:16px 0;
        display: flex;
        justify-content: space-between;
     }
     .buttoncon .sharch{
        display: flex;
        justify-content: space-between;
     }
.buttoncon .name{
margin-right: 40px;
     }
</style>